import Cookies from 'js-cookie'
// token key
 let TokenKey = 'Admin-token'
// 首页HomeIndexPath
 let HomeIndexPathKey = '/'
export default{
  TokenKey,
  HomeIndexPathKey,
  getToken(){
    let tokens =  Cookies.get(TokenKey)
    console.log("tokens",tokens)
  return tokens
},

  setToken(token) {
  return Cookies.set(TokenKey, token)
},

  removeToken() {
  return Cookies.remove(TokenKey)
},
/**
 * 解析服务端拿到的cookie
 * @param {*} cookie
 * @param {*} key
 */
 getCookie(cookie, key) {
  if (!cookie) return
  const arrstr = cookie.split('; ')
  for (let i = 0; i < arrstr.length; i++) {
    const temp = arrstr[i].split('=')
    if (temp[0] === key) return decode(temp[1])
  }
}

}